<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Show.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<%--<link rel="stylesheet" type="text/css" href="css/home.css">--%>
	<script type="text/javascript" src="/statics/js/jquery-1.12.4.js"></script>
	<script type="text/javascript">

	$(function () {
        $("#delete").click(function() {
            var ids="";
            alert("ffffffff");
            $("[name='more']:checked").each(function() {
               ids = ids+$(this).val() + ",";
            });
            alert("选中项：" + ids);
            $.ajax({
                url:"/user/del.html",
                data:{
                    "ids" : ids
                },
                dataType:"json",
                success:function(data){
                    if(data.flag){
                        for(var i=0;i<data.list.length;i++){
                            $("#"+data.list[i]).remove();
						}
                    }
                }
            })
        })
    })



	$(document).ready(function(){
	  /*  alert("================")*/
        show();
        $("#firstpage").click(function() {
            var nowPage = parseInt($("#now").html());
            $("#now").html(1);
            show();
        })
        $("#backpage").click(function() {
            var nowPage = parseInt($("#now").html());
            $("#now").html(nowPage - 1);
            show();
        })
        $("#nextpage").click(function() {
            var nowPage = parseInt($("#now").html());
            $("#now").html(nowPage + 1);
            show();
        })
        $("#lastpage").click(function() {
            var nowPage = parseInt($("#now").html());
            var contPage = $("#countPage").html();
            $("#now").html(contPage);
            show();
        })
        $("#search").click(function() {
            show();
        })

		function show() {
	        /*alert("展示========")*/
			var pageIndex=$("#now").html();
			var countPage=$("#countPage").html();
			var	zhname=$("#text").val();
            if (pageIndex >= countPage) {
                pageIndex = countPage;
                $("#now").html(countPage)
            }
            if (pageIndex <= 1) {
                pageIndex = 1;
                $("#now").html(1)
            }
            $.ajax({
				type:"POST",
				url:"/user/userlist.html",
				data:{
				    "zhname":zhname,
					"pageIndex":pageIndex
				},
				dataType:"JSON",
				success:function (data) {
                    var datajson=jQuery.parseJSON(data);
                    /*alert("datajson==="+datajson.list[1].zhname);*/
                    $("tr:gt(1)").remove();
					for (var i=0;i<datajson.list.length;i++){
					   var $json=$("<tr id='"+datajson.list[i].id+"'><td><input type='checkbox'name='more' value='" + datajson.list[i].id + "'/></td><td><span>"+
						   			datajson.list[i].stdnum+"</span></td><td><span>"+
						   			datajson.list[i].zhname+"</span></td><td><span>"+
						   			datajson.list[i].ver+"</span></td><td><span>"+
                           			datajson.list[i].keyes+"</span></td><td><span>"+
						   			datajson.list[i].releasedate+"</span></td><td><span>"+
						   			datajson.list[i].impldate+"</span></td><td><a href='/SSMDemo4/update?id="+
						   			datajson.list[i].id+"'>下载</a><a href='/user/update.html?id="+datajson.list[i].id+"'>修改</a></td></tr>")
						$("#table").append($json);
                    }
                    $("#countPage").html(datajson.totalPageCount);
                    $("#now").html(datajson.nowPage);
                    $("#text").val(datajson.zhname);
                }
			})
        }
    })

	function add() {
		window.location.href="${pageContext.request.contextPath }/user/useradd.html";
    }

	</script>
  </head>
  
  <body>
    <div id="div1">
		<table id="table" border="1">
			<tr>
				<td colspan="7" id="firsttd">
					<input type="text" id="text" />
					<input type="button" value="提交检索" id="search" />
					<input type="button" value="新增标准" id="addplay" onclick="add()"/>
					<input type="button" value="删除标准" id="delete" />
				</td>
			</tr>
			<tr id="tr1">
				<th>选项</th>
				<th>标准号</th>
				<th>中文名称</th>
				<th>版本</th>
				<th>关键字</th>
				<th>发布日期</th>
				<th>实施日期</th>
				<th>操作</th>
			</tr>
		</table>
		<p class="p">
			<a href="javascript:void(0);" id="firstpage">首页</a> |
			<a href="javascript:void(0);" id="backpage">上一页</a>|
			<a href="javascript:void(0);" id="nextpage">下一页</a>|
			<a href="javascript:void(0);" id="lastpage">末页</a> 第<span id="now"></span>页/共<span
				id="countPage"></span>页
		</p>
		<input type="hidden" name="hidden" value="1" id="nowpage" />
	</div>

    
  </body>
</html>
